﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.Bll;
using Acms.AcmsControls;

public partial class Templates_SubTemplates_VideoMov_Display : Acms.AcmsControls.TemplateUserControl
{
    protected override void OnInit(EventArgs e)
    {
        //base.OnInit(e);

        //base.DataBind();

        
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void ShowLnkHDTV720p_OnDataBound(object sender, EventArgs e)
    {
        var ShowLnkHDTV720p = FindPostControl("ShowLnkHDTV720p");
        var ShowLnkHDTV720pProp = ShowLnkHDTV720p.GetProperties<Acms.AcmsControls.TrueFalseContentControlProperties>();
        
        if (ShowLnkHDTV720pProp != null && ShowLnkHDTV720pProp.Value)
        {
            lnkHDTV720p.Visible = true;
        }
        else
        {
            lnkHDTV720p.Visible = false;
        }
        if (ShowLnkHDTV720pProp != null)
        {
            var ShowLnkHDTV720pValue = ShowLnkHDTV720p.Value;
        }
    }

    protected void ShowLnkMobile270p_OnDataBound(object sender, EventArgs e)
    {
        var ShowLnkMobile270p = FindPostControl("ShowLnkMobile270p");
        var ShowLnkMobile270pProp = ShowLnkMobile270p.GetProperties<Acms.AcmsControls.TrueFalseContentControlProperties>();

        if (ShowLnkMobile270pProp != null && ShowLnkMobile270pProp.Value)
        {
            lnknkMobile270p.Visible = true;
        }
        else
        {
            lnknkMobile270p.Visible = false;
        }
        if (ShowLnkMobile270pProp != null)
        {
            var ShowLnkMobile270pValue = ShowLnkMobile270p.Value;
        }
    }


    protected void ShowLnkWindows720p_OnDataBound(object sender, EventArgs e)
    {
        var ShowLnkWindows720p = FindPostControl("ShowLnkWindows720p");
        var ShowLnkWindows720pProp = ShowLnkWindows720p.GetProperties<Acms.AcmsControls.TrueFalseContentControlProperties>();

        if (ShowLnkWindows720pProp != null && ShowLnkWindows720pProp.Value)
        {
            lnkWindows720p.Visible = true;
        }
        else
        {
            lnkWindows720p.Visible = false;
        }
        if (ShowLnkWindows720pProp != null)
        {
            var ShowLnkWindows720pValue = ShowLnkWindows720p.Value;
        }
    }


    public override void DataBind()
    {
        base.DataBind();

        var post = AcmsContext.CurrentPost;
        if (post != null)
        {
            //var lnkThumb = FindControl("lnkThumb") as HyperLink;
            //var lnkDisplayName = FindControl("lnkDisplayName") as HyperLink;

            var lnkHDTV720p = FindControl("lnkHDTV720p") as HyperLink;
            if (lnkHDTV720p != null)
            {
                lnkHDTV720p.Text = "mp4(720)";
                lnkHDTV720p.NavigateUrl = "http://www.schiebel.net/FTPfolder/Video/" + post.Name + "_mp4-720.zip";
                lnkHDTV720p.ToolTip = post.DisplayName + "  mp4 (HDTV 720p)";
            }

            var lnknkMobile270p = FindControl("lnknkMobile270p") as HyperLink;
            if (lnknkMobile270p != null)
            {
                lnknkMobile270p.Text = "mp4(270)";
                lnknkMobile270p.NavigateUrl = "http://www.schiebel.net/FTPfolder/Video/" + post.Name + "_mp4-270.zip";
                lnknkMobile270p.ToolTip = post.DisplayName + " mp4 (Mobile 270p)";
            }

            var lnkWindows720p = FindControl("lnkWindows720p") as HyperLink;
            if (lnkWindows720p != null)
            {
                lnkWindows720p.Text = "wmv(720)";
                lnkWindows720p.NavigateUrl = "http://www.schiebel.net/FTPfolder/Video/" + post.Name + "_wmv-720.zip";
                lnkWindows720p.ToolTip = post.DisplayName + " wmv (Windows 720p)";
            }

            //lnkThumb.ToolTip = post.DisplayName;
            //lnkDisplayName.Text = post.DisplayName;
            //lnkThumb.NavigateUrl = "http://www.schiebel.net/FTPfolder/Video/" + post.Name + ".mp4";
            //lnkDisplayName.NavigateUrl = "http://www.schiebel.net/FTPfolder/Video/" + post.Name + ".mp4";
            //lnkDisplayName.Attributes.Add("rel", "#VideoPlayerWrapper");
            
            
            
            
            //if (lnkThumb != null)
            //{
            //    lnkThumb.ToolTip = post.DisplayName;
            //    lnkDisplayName.Text = post.DisplayName;
                
            //    //Add rel attribute
            //    lnkDisplayName.Attributes.Add("rel", "#VideoPlayerWrapper");

            //    var Image = post.FindPostControl("FlashVideo");// as ImageContentControlDisplay;
            //    if (Image != null)
            //    {
            //        var prop = Image.GetProperties<Acms.AcmsControls.FlashVideoContentControlProperties>();
            //        if (prop != null && prop.HasResource())
            //        {
            //            var host = HttpContext.Current.Request.Url.Host;
            //            var flvUrl = "http://" + HttpContext.Current.Request.Url.Host + ResolveUrl(Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, 500, null, this.Page));
            //            lnkThumb.NavigateUrl = flvUrl;
            //            lnkDisplayName.NavigateUrl = flvUrl;
            //        }
            //        else
            //        {
            //            lnkThumb.NavigateUrl = "NO_MOVIE";
            //            lnkDisplayName.NavigateUrl = "NO_MOVIE";
            //        }
            //    }
            //}
        }
    }
}
